/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ws;

import commonpackage.Order;
import commonpackage.POI;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import util.DBManagement;

/**
 *
 * @author chuda
 */
@WebService(name="ManagePOI")
public class ManagePOI {

    /**
     * Web service operation
     * Returns list of POIs by keyword
     */
    @WebMethod(operationName = "getPOIsByKW")
    public String[] getPOIsByKW(@WebParam(name = "keyword")
    String keyword) {
        DBManagement dbm = new DBManagement();
        String[] pois = dbm.selectPOIByKeyWord(keyword);
        System.out.println(pois);
        return pois;
    }

    /**
     * Web service operation
     * returns ALL the existent POIs in database
     */
    @WebMethod(operationName = "getAllPOIs")
    public String[] getAllPOIs() {
        DBManagement dbm = new DBManagement();
        String[]pois = dbm.selectAllPOIs();
       // System.out.println(pois);
        return pois;
    }

    /**
     * Web service operation
     * returns a POI by its ID
     */
    @WebMethod(operationName = "getPOIbyID")
    public String getPOIbyID(@WebParam(name = "poiid")
    int poiid) {
        DBManagement dbm = new DBManagement();
        POI poi = dbm.selectPOIByID(poiid);
       // System.out.println(pois);
        return poi.toString();
    }

     /**
     * Web service operation
      * cancels an order
     */
    @WebMethod(operationName = "cancelOrder")
    public String cancelOrder(@WebParam(name = "order")
    Order order) {
        DBManagement dbm = new DBManagement();
        String result = dbm.cancelOrder(order);
       // System.out.println(pois);
        return result;
    }

     /**
     * Web service operation
      * returns Eating poi by keyword
     */
    @WebMethod(operationName = "getEatingByKW")
    public String[] getEatingByKW(@WebParam(name = "keyword")
    String keyword) {
        DBManagement dbm = new DBManagement();
        return dbm.selectEatingByKeyWord(keyword);
    }

    /**
     * Web service operation
     * returns Hosting poi by keyword
     */
    @WebMethod(operationName = "getHostingByKW")
    public String[] getHostingByKW(@WebParam(name = "keyword")
    String keyword) {
        DBManagement dbm = new DBManagement();
        return dbm.selectHostingByKeyWord(keyword);
    }

     /**
     * Web service operation
      * returns travel poi by keyword
     */
    @WebMethod(operationName = "getTravelByKW")
    public String[] getTravelByKW(@WebParam(name = "keyword")
    String keyword) {
        DBManagement dbm = new DBManagement();
        return dbm.selectTravelByKeyWord(keyword);
    }

     /**
     * Web service operation
      * returns list of orders by mobile number
     */
    @WebMethod(operationName = "getOrdersByMobNumber")
    public String[] getOrdersByMobNum(@WebParam(name = "mobNumber")
    String mobNumber) {
        DBManagement dbm = new DBManagement();
        return dbm.selectOrdersByTelNumber(mobNumber);
    }

     /**
     * Web service operation
      * makes an order
     */
    @WebMethod(operationName = "makeOrder")
    public String makeOrder(@WebParam(name = "order")
    Order order) {
        DBManagement dbm = new DBManagement();
        return dbm.makeOrder(order);
    }

}
